 

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'organizers-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array(
		'class'=>'horizontal-form',
        'enctype'=>'multipart/form-data',  
    ),
)); ?>

<div class="form-body">
    <div class="row">
    	<div class="col-md-4">
            <fieldset>
        	<legend>Ảnh đại diện nhân vật</legend>
            <!-- Event Image -->
            <div class="fileinput fileinput-new btn-block" data-provides="fileinput">
                <?php if ($model->image != null) : ?>
                <div class="fileinput-new thumbnail" style="width:100%;">
                    <img src="<?php echo IMAGES_URL.'artists/' . date('Ymd', strtotime($model->createdate)) . '/' . $model->image; ?>" alt="..." width="100%">
                </div>
                <input type="hidden" value="<?php echo $model->image; ?>" name="Artists[currentImage]" />
                <?php endif; ?>
                <div class="fileinput-preview fileinput-exists thumbnail" style="max-width:100%"></div>
                <div>
                    <span class="btn btn-default btn-file btn-block"><span class="fileinput-new">Chọn ảnh nhân vật</span><span class="fileinput-exists">Chọn ảnh khác</span>
                    <?php echo $form->fileField($model, 'image', array('class'=>'default')); ?>
                    </span>
                    <a href="#" class="btn btn-default fileinput-exists btn-block" data-dismiss="fileinput">Xóa bỏ ảnh hiện tại</a>
                </div>
            </div>
            	 <?php if(Yii::app()->user->hasFlash('error')): ?>
		                <div class="errorMessage">
		                    <?php echo Yii::app()->user->getFlash('error'); ?>
		                </div>
	                <?php endif; ?>
            </fieldset>
 		</div>
        <div class="col-md-8">
            <fieldset>
        	<legend>Ảnh cover nhân vật</legend>
            <!-- Event Image -->
            <div class="fileinput fileinput-new btn-block" data-provides="fileinput">
                <?php if ($model->imagecover != null) : ?>
                <div class="fileinput-new thumbnail" style="width:100%;">
                    <img src="<?php echo IMAGES_URL.'artists/' . date('Ymd', strtotime($model->createdate)) . '/' . $model->imagecover; ?>" alt="..." width="100%">
                </div>
                <input type="hidden" value="<?php echo $model->imagecover; ?>" name="Artists[currentImagecover]" />
                <?php endif; ?>
                <div class="fileinput-preview fileinput-exists thumbnail" style="max-width:100%"></div>
                <div>
                    <span class="btn btn-default btn-file btn-block"><span class="fileinput-new">Chọn ảnh Cover</span><span class="fileinput-exists">Chọn ảnh khác</span>
                    <?php echo $form->fileField($model, 'imagecover', array('class'=>'default')); ?>
                    </span>
                    <a href="#" class="btn btn-default fileinput-exists btn-block" data-dismiss="fileinput">Xóa bỏ ảnh hiện tại</a>
                </div>
            </div>
            	 <?php if(Yii::app()->user->hasFlash('error')): ?>
		                <div class="errorMessage">
		                    <?php echo Yii::app()->user->getFlash('error'); ?>
		                </div>
	                <?php endif; ?>
            </fieldset>
 		</div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <fieldset>
        	<legend>Ảnh cover nhân vật</legend>
 			<div class="col-md-6">
                <div class="form-group <?php echo ($model->getError('nickname') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'nickname', array('class'=>'control-label')); ?>
					<?php echo $form->textField($model,'nickname', array('class'=>'form-control')); ?>
					<?php echo $form->error($model,'nickname', array('class'=>'help-block')); ?>
				</div>
	 			<div class="form-group <?php echo ($model->getError('fullname') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'fullname', array('class'=>'control-label')); ?>
					<?php echo $form->textField($model,'fullname', array('class'=>'form-control')); ?>
					<?php echo $form->error($model,'fullname', array('class'=>'help-block')); ?>
				</div>
	 			<div class="form-group <?php echo ($model->getError('email') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'email', array('class'=>'control-label')); ?>
					<?php echo $form->textField($model,'email', array('class'=>'form-control')); ?>
					<?php echo $form->error($model,'email', array('class'=>'help-block')); ?>
				</div>
			</div>
			<div class="col-md-6">
	 			<div class="form-group <?php echo ($model->getError('gender') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'gender', array('class'=>'control-label')); ?>
					<?php echo $form->dropDownList($model,'gender',array('N'=>'Nữ','F'=>'Nam'), array('class'=>'form-control')); ?>
					<?php echo $form->error($model,'gender', array('class'=>'help-block')); ?>
				</div>
	 			<div class="form-group <?php echo ($model->getError('dateofbirth') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'dateofbirth', array('class'=>'control-label')); ?>
					<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                        'model'=>$model,
                                        'attribute' => 'dateofbirth',
                                        'language'=>Yii::app()->language=='vi' ? 'vi' : null,
                                        'options'=>array(
                                            'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
                                            'showOn'=>'focus', // 'focus', 'button', 'both'
                                            'buttonImageOnly'=>false,
                                            'showAnim'=>'clip',
                                            'changeMonth'=>true,
                                            'changeYear'=>true,
                                            'showButtonPanel'=>true,
                                            'dateFormat' => "yy-mm-dd",
                                            'buttonImageOnly'=>true,
                                            //'minDate'=>'1000',
                                            'yearRange' => "1940:2010",
                                        ),
                                        'htmlOptions'=>array(
                                            'style'=>'vertical-align:top',
                                            'placeholder'=>"2012-06-20",
                                            'class'=>'form-control'
                                        ),
                                    ));
                    ?>
					<?php echo $form->error($model,'dateofbirth', array('class'=>'help-block')); ?>
				</div>
                <div class="form-group <?php echo ($model->getError('status') ? 'has-error' : ''); ?>">
					<?php echo $form->labelEx($model,'status', array('class'=>'control-label')); ?>
					<?php echo $form->dropDownList($model,'status',array('A'=>'Hoạt động','I'=>'Ngừng hoạt động'), array('class'=>'form-control')); ?>
					<?php echo $form->error($model,'status', array('class'=>'help-block')); ?>
				</div>
			</div>
            <div class="form-group">
                <div class="form-group <?php echo ($model->getError('brief') ? 'has-error' : ''); ?>">
                    <?php echo $form->labelEx($model,'brief', array('class'=>'control-label')); ?>
                    <?php echo $form->textArea($model,'brief', array('class'=>'form-control','rows'=>5)); ?>
                    <?php echo $form->error($model,'brief', array('class'=>'help-block')); ?>
                </div>
            </div>
			<div class="form-group <?php echo ($model->getError('description') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($profile,'description', array('class'=>'control-label')); ?>
				<?php $this->widget('application.extensions.ckeditor.CKEditor', array(
                            'model'=>$profile,
                            'attribute'=>'description',
                            'language'=>'vi',
                            'editorTemplate'=>'full',
                            'options'=>array(
                                'height'=>'400px',
                            ),
                            'htmlOptions'=>array('rows'=>20,'class'=>'form-control'),
                        )); ?>
				<?php echo $form->error($profile,'description', array('class'=>'help-block')); ?>
			</div>	

			<!-- PLACE SOCIAL -->
			        <div class="col-md-12 row">
			            <div id="listSocial">
			                <?php if ($model->isNewRecord):?>
			                    <div class="row">
			                        <div class="col-md-5">
			                            <div class="form-group <?php echo ($social->getError('social_id') ? 'has-error' : ''); ?>">
			                                <?php echo CHtml::activelabelEx($social, 'social_id', array('class'=>'control-label')); ?>
			                                <?php echo CHtml::dropDownList('ArtistSocial[social_id][]', '',PlaceSocial::model()->getSocial(), array('class'=>'form-control', 'prompt'=>'Chọn Social')); ?>
			                                <?php echo CHtml::error($social, 'social_id', array('class'=>'help-block')); ?>
			                            </div>
			                        </div>
			                        <div class="col-md-1">AND</div>
			                        <div class="col-md-6">
			                            <div class="form-group <?php echo ($social->getError('url') ? 'has-error' : ''); ?>">
			                                <?php echo CHtml::activelabelEx($social, 'url', array('class'=>'control-label')); ?>
			                                <?php echo CHtml::textField('ArtistSocial[url][]', '', array('class'=>'form-control',)); ?>
			                                <?php echo CHtml::error($social, 'url', array('class'=>'help-block')); ?>
			                            </div>
			                        </div>
			                    </div>
			                <?php else:?>
			                    <?php foreach($social as $data):?>
			                        <div class="row">
			                            <div class="col-md-5">
			                                <div class="form-group <?php echo ($data->getError('social_id') ? 'has-error' : ''); ?>">
			                                    <?php echo CHtml::activelabelEx($data, 'social_id', array('class'=>'control-label')); ?>
			                                    <?php echo CHtml::dropDownList('ArtistSocial[social_id][]', $data->social_id,PlaceSocial::model()->getSocial(), array('class'=>'form-control', 'prompt'=>'Chọn Social')); ?>
			                                    <?php echo CHtml::error($data, 'social_id', array('class'=>'help-block')); ?>
			                                </div>
			                            </div>
			                            <div class="col-md-1">AND</div>
			                            <div class="col-md-6">
			                                <div class="form-group <?php echo ($data->getError('url') ? 'has-error' : ''); ?>">
			                                    <?php echo CHtml::activelabelEx($data, 'url', array('class'=>'control-label')); ?>
			                                    <?php echo CHtml::textField('ArtistSocial[url][]', $data->url, array('class'=>'form-control',)); ?>
			                                    <?php echo CHtml::error($data, 'url', array('class'=>'help-block')); ?>
			                                </div>
			                            </div>
			                        </div>
			                    <?php endforeach;?>
			                <?php endif;?>
			            </div>
						<a href="javascript: void(0);" class="btn green pull-right" onclick="addSocial();"><i class="icon-plus"> </i> Thêm Social</a>
                </div>
          </div>
    </div>
                <?php echo CHtml::submitButton('Lưu', array('class'=>'btn green', 'style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Refresh', array('onClick'=>'window.location="'.Yii::app()->getRequest()->getUrl().'"','class'=>'btn btn-beoro-3','style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Back', array('onClick'=>'history.go(-1)','class'=>'btn btn-beoro-3', 'style'=>'margin-right : 10px'));?>
 
   
        <?php $this->endWidget(); ?>
 <script type="text/javascript">
var i = 1;
function addSocial()
{
    $.ajax({
        url: '<?php echo Yii::app()->createUrl("/Events/request/artistsAddSocial");?>',
        type: 'post',
        data: {i: i},
        success: function (data)
        {
             i = i+ 1;
            $(data).appendTo('#listSocial');
        }
    });
}
 </script>